<template>
	<!-- 月总计划 -->
	<view class="body">
		<myHeader :title="title"></myHeader>
		<uni-search-bar @confirm="sreachIt()" :focus="false" v-model="search" @clear="clear"></uni-search-bar>
		<view v-if="currentRoleCode.includes('fl-leader')">
			<uni-fab :pattern="btnPattern" @fabClick="pageTo('./addMonthEndPlan')"></uni-fab>
		</view>
		<!-- 人物列表 -->
		<uni-list v-for="(item,index) in taskList" :key="item.id">
			<uni-list-item :title="item.theme==null?'无标题':item.name" link="navigateTo" @click="pageTo1('./addMonthEndFile',item)" :note="item.room">
			</uni-list-item>
		</uni-list>

	</view>
</template>

<script>
	import myHeader from '../../components/head.vue'
	import NetWorkTool from '@/api/netWorkTool'
	export default {
		data() {
			return {
				title: ' 月总计划',
				search: '',
				btnPattern: {
					buttonColor: '#e20909'
				},
				taskList: [{
					id: '1',
					name: '任务1',
					status: '待分配',
					file: '',
					summaryFile:'',
					createUser:''
				}],
				// 当前用户角色
				currentRoleCode: []
			}
		},
		mounted() {
			this.getLoginUserRoles();
			this.getList();
		},
		methods: {
			// 获取列表
			getList() {
				let param = {
					"current": 1,
					"pageSize": 10,
					"param": {
						"name": this.search,
					}
				}
				NetWorkTool.POST('/api/federation-end-month/getPage',param,true).then(res => {
					this.taskList = res.records;
				})
			},
			// 获取登录用户角色
			getLoginUserRoles() {
				let _this = this;
				uni.getStorage({
					key: 'user',
					success(e) {
						let arr = [];
						for (let item of e.data.role) {
							if (null != item.roleCode) {
								_this.currentRoleCode.push(item.roleCode)
							}
						}
					}
				})
			},
			pageTo(val) {
				uni.navigateTo({
					url: val
				})
			},
			pageTo1(val,data) {
				uni.navigateTo({
					url: val + "?data=" + JSON.stringify(data)
				})
			},
			sreachIt: function() { //键盘输入
				uni.showToast({
					title: this.search,
					duration: 1000
				})
				this.getList();
			},
			clear(){
				this.search = ''
				this.getList()
			}

		},
		components: {
			myHeader
		},
	}
</script>

<style>
</style>
